package com.creawor.km.util;

import java.util.Timer;
import java.util.TimerTask;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import client.sms.SMSService;

public class MessageMg implements ServletContextListener  {
	private Timer timer = null;

  public void contextInitialized(ServletContextEvent event) {
     try {
			timer = new Timer(true);
			 //timer.schedule(new MyTask(), 0, 1000*60*60*24*7*4);
			 timer.schedule(new MyTask(), 0, 1000*60);
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
   }

  public void contextDestroyed(ServletContextEvent event) {
     timer.cancel();
   }

}
class MyTask extends TimerTask {
	client.sms.SMSService service= new SMSService();
  public void run() {
  	
  	try {
			service.getRevert();
			System.out.println("this is a task!!");
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
    
   }

}
